

exports.install = function (Vue, options) {


  var socket

  Vue.prototype. init=function () {
    if(typeof(WebSocket) === "undefined"){
      alert("您的浏览器不支持socket")
    }else{
      // 实例化socket
      socket = new WebSocket(this.path)
      // 监听socket连接
      socket.onopen = this.open
      // 监听socket错误信息
      socket.onerror = this.error
      // 监听socket消息
      socket.onmessage = this.getMessage


    }
  },
  Vue.prototype.open= function () {
    console.log("socket连接成功")
  },
  Vue.prototype.error= function () {
    console.log("连接错误")
  },
  Vue.prototype. getMessage= function (msg) {
    console.log(msg.data)
   // this.GLOBAL.setMessage("new")
    window.sessionStorage.setItem("massage","new")
    var ff=  window.sessionStorage.getItem("massage")
    console.log(ff)
    this.$notify({
      title: '成功',
      message: '你收到一条信息',
      type: 'success',
      duration:2000
    });

  },

    Vue.prototype. send= function () {
      // console.log(this.massage)
      // var kk=JSON.stringify(this.massage)
      socket.send(kk);
    }
  Vue.prototype.close= function () {
    console.log("socket已经关闭")
  }



};
